/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package share;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author mire
 */
public class RedirectOut {
//TODO redirect u tab bre
    private String fileName;
    private PrintStream outStream = null;
    private PrintStream errStream = null;
    private PrintStream fileStream = null;

    public RedirectOut(String fileName) {
        this.fileName = "." + fileName + ".log";
    }
        

    public void start() {
        try {
            outStream = System.out;
            errStream = System.err;
            fileStream = new PrintStream(new FileOutputStream(fileName, true));

            System.setOut(fileStream);
            System.setErr(fileStream);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(RedirectOut.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void stop() {
        System.setOut(outStream);
        System.setErr(errStream);
    }
}
